---
title: dcmi_get_device_errorinfo接口原型
description: "int dcmi_get_device_errorinfo(int card_id, int device_id, int errorcode, unsigned char *errorinfo, int buf_size)"
url: "https://www.hiascend.com/document/detail/zh/Atlas%20200I%20A2/260RC1/re/api/api_030.html"
---

# dcmi_get_device_errorinfo接口原型

#### 函数原型

int dcmi_get_device_errorinfo(int card_id, int device_id, int errorcode, unsigned char *errorinfo, int buf_size)


#### 功能说明

查询设备故障描述。


#### 参数说明

| 参数名称 | 输入/输出 | 类型 | 描述 |
| --- | --- | --- | --- |
| card\_id | 输入 | int | 设备ID，当前实际支持的ID通过dcmi\_get\_card\_num\_list接口获取。 |
| device\_id | 输入 | int | 芯片ID，通过dcmi\_get\_device\_id\_in\_card接口获取。取值范围如下： NPU芯片：[0, device\_id\_max\-1]。 |
| errorcode | 输入 | int | 要查询的错误码，通过dcmi\_get\_device\_errorcode\_v2接口获取。 |
| errorinfo | 输出 | unsigned char \* | 对应的错误字符描述。 |
| buf\_size | 输入 | int | 传入的errorinfo大小，固定为48字节。若设置的buffer大小大于48字节，则默认用48字节。 |


#### 返回值说明

| 类型 | 描述 |
| --- | --- |
| int | 处理结果： 成功：返回0。 失败：返回码请参见返回码。 |


#### 异常处理

无。


#### 约束说明

该接口在后续版本将会被删除，推荐使用dcmi_get_device_errorcode_string接口原型。


**表1 不同部署场景下的支持情况**

| 物理机场景（裸机） | 物理机场景（裸机） | 物理机+普通容器场景 |
| --- | --- | --- |
| root用户 | 运行用户组（非root用户） | root用户 |
| Y | Y | Y |
| 注：Y表示支持；N表示不支持；NA表示不涉及，当前未规划此场景。 | 注：Y表示支持；N表示不支持；NA表示不涉及，当前未规划此场景。 | 注：Y表示支持；N表示不支持；NA表示不涉及，当前未规划此场景。 |


#### 调用示例

```
#define ERROR_CODE_MAX_NUM  (128)
#define BUF_SIZE          (48)
…
int ret = 0;
int card_id = 0;
int device_id = 0;
int errorcount = 0;
int error_code_width = 0;
unsigned char errorinfo[BUF_SIZE] = {0};
unsigned char errorcode[ERROR_CODE_MAX_NUM] = {0};
ret = dcmi_get_device_errorcode_v2(card_id, device_id, &errorcount, errorcode, &error_code_width);
if ((ret != 0) || (errorcount == 0)){
//todo:记录日志
return ret;
}
ret = dcmi_get_device_errorinfo(card_id, device_id, errorcode[0], errorinfo, BUF_SIZE);
if (ret != 0){
//todo:记录日志
return ret;
}
…
```
